<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<script type="text/javascript">
	//初始化日志页面
	$(document).ready(function() {
		var operationType='${operationType}';
		var $Blog_tip_success = $("#Blog_tip_success");
		if(operationType!="" && operationType!=null){
			if (operationType == 'postSuccess') {
				if ($Blog_tip_success.css("display") == 'none') {
					$Blog_tip_success.append("发送日志成功!");
					$Blog_tip_success.fadeIn(1000);
					$Blog_tip_success.fadeOut(1000);
				}
			}
			if (operationType == 'deleteSuccess') {
				if ($Blog_tip_success.css("display") == 'none') {
					$Blog_tip_success.append("删除日志成功!");
					$Blog_tip_success.fadeIn(1000);
					$Blog_tip_success.fadeOut(1000);
				}
			}
			if (operationType == 'editSuccess') {
				if ($Blog_tip_success.css("display") == 'none') {
					$Blog_tip_success.append("编辑日志成功!");
					$Blog_tip_success.fadeIn(1000);
					$Blog_tip_success.fadeOut(1000);
				}
			}
		}
		var familyType=$("#familyType").val();
		if(familyType=="myFamilyType"){
			$("#newNews1").attr("class", "h_newNewsHover");
			$("#newNews2").attr("class", "");
		}
		if(familyType=="friendFamilyType"){
			$("#newNews1").attr("class", "");
			$("#newNews2").attr("class", "h_newNewsHover");
		}
	});
	
	//写新日记
	function enterPostBlog() {
		$("#divBlogList").load("enterPostBlog.htm");
	}
	//评论和读日志
	function enterComment(id) {
		$.ajax({
			type : "GET",
			url : "enterBlogComment.htm",
			data : "id=" + id,
			success : function(data) {
				$("#divBlogList").html(data);
			}
		});
	}
	//删除日志
	function delBog() {
		$.unblockUI();
		$.ajax({
			type : "GET",
			url : "delBlog.htm",
			data : "id=" + $("#blogId").val(),
			success : function(data) {
				$("#content_detail").load(
						"enterBlog.htm?&operationType=deleteSuccess");

			}
		});
	}
	//编辑日志
	function enterEditBog(id) {
		$.ajax({
			type : "GET",
			url : "enterEditBlog.htm",
			data : "id=" + id,
			success : function(data) {
				$("#divBlogList").html(data);
			}
		});
	}
	//弹出删除浮层	
	function showDeleteDiv(id) {
		$("#blogId").val(id);
		$('.h_delete').show();
		/*
		$.blockUI({
			message : $('.h_delete'), // message to display
			css : {
				cursor : 'hand',
				border : '0px'
			}
		});*/
	}
	function mBlog() {
		$("#content_detail").load("enterBlog.htm?familyType=myFamilyType");
	}
	function friendBlog() {
		$("#content_detail").load("enterBlog.htm?familyType=friendFamilyType");
	}
	//隐藏浮层
	function hideDeleteDiv() {
		//$.unblockUI();
		$('.h_delete').hide();
	}
	//分页
	$(function(){
		$("#pager").pager({ pagenumber: ${pageIndex}, pagecount: ${pageCount}, buttonClickCallback: PageClick });
	});
	function PageClick(pageclickednumber) {
	    page(pageclickednumber);
	}
	function page(clickPage){
			$.ajax({
				type:"GET",
				url:"enterBlog.htm",
				data:{'pageIndex':clickPage,'classname':$("#classname").val(),'familyType':$("#familyType").val()},
				success:function(data){
					$("#content_detail").html(data);
					}
			});
	}
	//选择日志类别
	function getBlogByType(aHref){
		var $aHref=$(aHref);
		$(".current").attr("class", "");
		$aHref.attr("class", "current");
		var classname=$(aHref).attr("title");
		var familyType=$("#familyType").val();
		$("#content_detail").load("enterBlog.htm?familyType="+$("#familyType").val()+"&classname="+classname);
	}
</script>
<div class="h_main2" id="mainBlog">
	<div class="h_data">
		<h2 id="tips">
			<img src="images/home_images/ico28.png" alt="日志" />日志
		</h2>
		<div id="Blog_tip_success" class="success"
			style="margin-left: 30px; display: none;">
			<img alt="修改成功" src="images/home_images/ico29.png">
		</div>
		<div class="h_newNews">
			<ul>
				<li id="newNews1" class="h_newNewsHover"><a onclick="mBlog();">家的日志</a>
				</li>
				<li id="newNews2"><a onclick="friendBlog();">邻居的日志</a>
				</li>
				<span style="font-size: 12px; line-height: 22px;"><a
					href="javascript:void(0);" onclick="enterPostBlog();">写新日志</a> </span>
				<div class="clear"></div>
			</ul>
			<div class="clear"></div>
		</div>

		<div id="divBlogList">
			<div class="h_newNews_box">
				<input type="hidden" name="classname" value="${classname }"
					id="classname" /> <input type="hidden" name="familyType"
					value="${familyType }" id="familyType" />
				<div class="h_newNews_text" id="con_newNews_1"
					style="display: block;">
					<div class="data_h_newNews_nav" id="divClassType">
						<a href="#" <c:if test="${classname==null}">class='current'</c:if>
							onclick="getBlogByType(this);" title="">全部日志(${allBlogCount
							})<c:if test="${classname==null}"></c:if> </a>
			<c:forEach items="${blogExtList}" var="blogExt">
				 <a href="javascript:void(0)" <c:if test="${classname==blogExt.classname}">class='current'</c:if> onclick="getBlogByType(this);" title="${blogExt.classname }">${blogExt.classLabel }(${blogExt.blogCount})</a>
			</c:forEach>


					</div>

					<div class="clear"></div>
					<c:if test="${ empty bList }">
						<c:if test="${familyType =='friendFamilyType'}">
							<div id="base_info_tip_success" class="success">您的邻居还没有发表日志哦！</div>
						</c:if>
						<c:if test="${familyType =='myFamilyType'}">
							<div id="base_info_tip_success" class="success">您还没有写日志，点击“写新日志”开始写您的日志吧。</div>
						</c:if>
					</c:if>
					<c:if test="${not empty bList}">
						<c:forEach items="${bList}" var="blog">
							<div class="h_logBox">
								<div class="h_logTop">
									<div class="newsList_img2 mr10">
										<div class="own_img">
											<img alt="我的好友" width="58" height="58"
												src="${blog.memberAvatar }">
										</div>
										<div class="others_img">
											<img width="24" height="24" alt="果果街"
												src="${blog.familyAvatar }">
										</div>
									</div>
									<h2>
										<span> <c:if test="${member.identifier==blog.members }">
												<a href="javascript:void(0);"
													onclick="enterEditBog('${blog.identifier }'); "
													id="editBlog">编辑</a>| 
							<a href="javascript:void(0)" id="delBlog"
													onclick="showDeleteDiv(${blog.identifier });">删除</a>
											</c:if> </span> <a href="javascript:void(0)"
											onclick="enterComment('${blog.identifier }'); "><c:out value="${blog.subject}"></c:out></a>
									</h2>
									<div class="h_logTime">
										<span> <fmt:formatDate value="${blog.gmtCreated}"
												pattern="yyyy-MM-dd HH:mm" type="time" timeStyle="full" />
										</span> <span> <strong>${blog.username}</strong> 发表 </span> <span>分类：${blog.classLabel}</span>
										<span>权限：${blog.visibility}</span>
									</div>
									<div class="clear"></div>
								</div>
								<div class="h_logText">

									<div id="divContent">
										<p>${blog.summeryContent}</p>
									</div>

									<div class="h_logImg"></div>
									<div class="h_logYl">
										<a id="blogReply" href="javascript:void(0)"
											onclick="enterComment('${blog.identifier }'); ">${blog.replyAmount}条评论</a>
										<%--|<a href="#">赞</a> --%>
									</div>
									<div class="clear"></div>
								</div>
							</div>
						</c:forEach>
					</c:if>

					<div class="h_delete" style="display: none;">
						<h4>
							<input type="hidden" id="blogId" /> <a href="#"
								id="hidedelBlogDiv" onclick="hideDeleteDiv();"></a>删除日志
						</h4>
						<div class="h_delete_text">
							<p>
								你确定要删除该日记?<br />删除后无法恢复!
							</p>
							<div class="h_button fl" onclick="delBog(${blog.identifier});">
								<strong>删 除</strong>
							</div>
							<div class="h_button fl ml5" onclick="hideDeleteDiv();">
								<strong>取 消</strong>
							</div>
						</div>
					</div>
				</div>
				<div class="h_page" id="pager"></div>
				<div></div>
				<div></div>
			</div>
			
		</div>
	</div>
</div>
